package com.example.othree.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.othree.entity.Aot40HistoryDayDataHsxt;
import com.example.othree.entity.WeatherStationInfo;
import com.example.othree.mapper.Aot40HistoryDayDataHsxtMapper;
import com.example.othree.mapper.WheatCornGrowthYearMapper;
import com.example.othree.service.Aot40HistoryDayDataHsxtService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zogran
 * @since 2024-11-12
 */
@Service
public class Aot40HistoryDayDataHsxtServiceImpl extends ServiceImpl<Aot40HistoryDayDataHsxtMapper, Aot40HistoryDayDataHsxt> implements Aot40HistoryDayDataHsxtService {
    @Resource
    Aot40HistoryDayDataHsxtMapper aot40HistoryDayDataHsxtMapper;

    @Resource
    WheatCornGrowthYearMapper wheatCornGrowthYearMapper;

    @Override
    public IPage PageList(IPage<Aot40HistoryDayDataHsxt> page, Wrapper wrapper) {
        return aot40HistoryDayDataHsxtMapper.PageList(page,wrapper);
    }

    @Override
    public List<Aot40HistoryDayDataHsxt> spaceDataByGrowth(String city, String element, String year, String crop, String startPeriod, String endPeriod) {

        String startDate = wheatCornGrowthYearMapper.TimeByYearForCrop(startPeriod, city, year, crop);

        return aot40HistoryDayDataHsxtMapper.spaceData(city, element, year, crop, startPeriod, endPeriod);
    }

    @Override
    public ArrayList<Aot40HistoryDayDataHsxt> spaceDataForDay(String city, String district, String element, String year, String crop, String startPeriod, String endPeriod) {

        String startDate = wheatCornGrowthYearMapper.TimeByYearForCrop(startPeriod, district, year, crop);
        String endDate = wheatCornGrowthYearMapper.TimeByYearForCrop(endPeriod, district, year, crop);
        System.out.println(startDate + "--" + endDate);

        return aot40HistoryDayDataHsxtMapper.spaceDataForDay(city, district, element, year, crop, startDate, endDate);
//        return aot40HistoryDayDataHsxtMapper.spaceDataForDay(city, district, element, year, crop, "2016-10-08", "2017-06-10");
    }

    @Override
    public ArrayList<WeatherStationInfo> lonLatInfo() {
        return aot40HistoryDayDataHsxtMapper.lonLatInfo();
    }

    @Override
    public List<Map<String, Object>> countyToLonLat(String city) {
        return aot40HistoryDayDataHsxtMapper.countyToLonLat(city);
    }
}
